package cn.iocoder.yudao.module.system.framework.translate.core;

import cn.iocoder.yudao.module.system.framework.translate.core.impl.GoogleFreeTranslateClientImpl;
import cn.iocoder.yudao.module.system.framework.translate.core.impl.GoogleTranslateClientImpl;
import cn.iocoder.yudao.module.system.framework.translate.enums.TranslateChannelEnum;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * Description:
 * Author: li
 * Date: 2024/2/20
 */
@Component
public class TranslateClientFactory {
    @Resource
    private GoogleTranslateClientImpl googleTranslateClient;
    @Resource
    private GoogleFreeTranslateClientImpl googleFreeTranslateClient;

    public ITranslateClient getTranslateClient(TranslateChannelEnum channel) {
        final ITranslateClient client;
        switch (channel) {
            case GOOGLE:
                client = googleTranslateClient;
                break;
            case GOOGLE_FREE:
                client = googleFreeTranslateClient;
                break;
            default:
                throw new IllegalArgumentException(String.format("未知的channel [%s]", channel));
        }
        return client;
    }

}
